home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / YICN23.ZIP / UNITS / YAKSTICK.CPP < prev    next >
C/C++ Source or Header  |  1993-02-14  |  801b  |  47 lines

  1. #define YAKSTICKUNIT
  2. //yakIcons implementation of Christopher Christensen's joystick routines
  3. #include "yakstick.h"
  4.  
  5. yakStick joyStick1(1), joyStick2(2);
  6.  
  7. extern int jstk1_x;
  8. extern int jstk2_x;
  9. extern int jstk1_y;
  10. extern int jstk2_y;
  11. extern "C" int read_jstk(void);
  12.  
  13. int yakStick::read(void)
  14. {
  15.   int buttons = read_jstk();
  16.   x = (stickNumber == 1) ? jstk1_x : jstk2_x;
  17.   y = (stickNumber == 1) ? jstk1_y : jstk2_y;
  18.   if (stickNumber != 1)
  19.     buttons >>= 2;
  20.   button1 = buttons & 0x01;
  21.   button2 = buttons & 0x02;
  22. }
  23.  
  24. int yakStick::readX(void)
  25. {
  26.   read();
  27.   return x;
  28. }
  29.  
  30. int yakStick::readY(void)
  31. {
  32.   read();
  33.   return y;
  34. }
  35.  
  36. byte yakStick::readButton1(void)
  37. {
  38.   read();
  39.   return button1;
  40. }
  41.  
  42. byte yakStick::readButton2(void)
  43. {
  44.   read();
  45.   return button2;
  46. }
  47.